"""
学习python
"""
from openpyxl.styles.builtins import total

'''
学习
'''
"hello"

import pandas as pd
import random
from random import randint

# print(1+2+3/4)
# print(1/3)
# print(2/3)
#
# a:int=1
# print(f'a:{type(a)}')
# res:float=1/3
# print(f"res:{type(res)}")
#
# avg = (67.5 + 89.0 + 12.9 + 32.2) / 4
# total = (67.5 - avg) ** 2 + (89.0 - avg) ** 2 + (12.9 - avg) ** 2 + (32.2 - avg) ** 2
# # ** 表示乘方，**2表示二次方
# result = total / 3
# print(result)
#
# b:int=2**3
# print(b)
# print(f'b:{type(b)}')
# b=2*3
# print(b)
# b=5**0.5
# print(b)
#
# # 向下取整
# a=7//2
# print(a)
# a=-7//2
# print(a)
#
# str1:str="hello"
# str2:str='hello'
# print(f'{len(str1)}')
# print(f"str1:{type(str1)}")
# print(f'str2:{type(str2)}')
#
# str3="""hello "nihao" 'zaijian'"""
# print(str3)
# str4='''hello 'nihao' "zaijian"'''
# print(str4)
#
# # 动态类型
# a:bool=True
# print(f'a:{type(a)}')
#
# b:bool=False
# print(f"b:{type(b)}")

# a=input("输入数据：")
# print(a)
# print(f'a:{type(a)}')
#
# print("输入三个数求和")
# f1=input("输入第一个：")
# f2=input("输入第二个：")
# f3=input("输入第三个：")
# print(f'三数之和：{f1+f2+f3}')
# f1=int(f1)
# f2=int(f2)
# f3=int(f3)
# print(f'三数之和：{f1+f2+f3}')

# a=0.1
# b=0.2
# c=0.3
# print(a+b==c)
# print(c)
# print(a+b)
# print(-0.0000001<a+b-c<0.0000001)
#
# print(a<0 and b<0)
# print(a>0 or b<0)
# print(not(a<0 and b<0))
#
# str1='abcd'
# str2='abce'
# print(str1<str2)

# while True:
#     a = input("输入：")
#     a = int(a)
#
#     if a < 3:
#         print("nihao")
#     elif a < 6:
#         print("zaijian")
#     elif a < 9:
#         print("hello")
#     elif a < 10:
#         pass
#     else:
#         print("haha")
#         break
# # range(m,n,k)--> [m,n)每次步长为k，k默认1
# for i in range(1,11):
#     print(i)
#
# for i in range(1,100,3):
#     print(i)
#
# for i in range(20,2,-2):
#     print(i)
# print(f"i:{i}")
#
# def Sum(begin=1,end=10):
#     temp=0
#     for i in range(begin,end+1):
#         temp+=i
#     return temp
#
# sum1=Sum()
# print(f"sum1:{sum1}")
# sum2=Sum(5)
# print(f"sum2:{sum2}")
# sum3=Sum(200,300)
# print(f"sum3:{sum3}")
#
# def Print(a,b,c):
#     print(a,b,c)
#
#
# Print(10,"nihao",True)
#
# def Ret():
#     x=10
#     y=20
#     return x,y
# a,b=Ret()
# print(f"a:{a}",f"b:{b}")
#
# x=Ret()
# print(f"x:{x}")
#
# _,n=Ret()
# print(f"n:{n}")
#
# x=100
# print(f"x:{x}")
# def change():
#     x=88
# change()
# print(f"change():{x}")
#
# def ChangeX():
#     global x
#     x=99
# ChangeX()
# print(f"ChangeX():{x}")

# def a():
#     numa=10
#     print("aaa")
#
# def b():
#     numb=20
#     a()
#     print("bbb")
#
# def c():
#     numc=30
#     b()
#     print("ccc")
#
# def d():
#     numd=40
#     c()
#     print("ddd")
#
# # d()
# # 求n！
# def factor(n):
#     if n==1:
#         return n
#     return n*factor(n-1)
#
# # print(factor(100))
# def add(x,y):
#     print(f'x:{x}')
#     print(f'y:{y}')
#
# add(10,20)
# add(x=30,y=40)
# add(y=50,x=60)

# l1=["nihao",'haha',True,10,1.22,10+20]
# print(l1)
# print("------------------")
#
# l1.append(False)
# for i in l1:
#     print(i)
#     print(type(i))
# print("------------------")
# l1.clear()
# for i in l1:
#     print(i)
#     print(type(i))
# l1=[0,1,2,3,4,5,6,7,8,9]
# # 输出l1的倒数第二个
# print(l1[-2])
#
# # 取出[0,4)区间的元素
# l2=l1[:4]
# print(f'l2:{l2}')
#
# # 取出2位置之后的所有元素
# l2=l1[2:]
# print(f'l2:{l2}')
#
# # 取出[0,5)区间的元素，每次步长为2
# l3=l1[2:5:2]
# print(f'l3:{l3}')
#
# # 取出2~倒数第二个区间的元素，每次步长为1
# l4=l1[2:-2:1]
# print(f'l4:{l4}')
#
# # 倒着取数据，每次步长为2
# l5=l1[::-2]
# print(f'l5:{l5}')

# l=[1,2,3,4,5,6,7,8,9]
# print(l)

#for elem in l:
#     elem+=10
# print(l)
#
# for i in range(0,len(l)):
#     l[i]+=10
# print(l)
#
# i=0
# while i<len(l):
#     print(l[i])
#     i+=1
# 在末尾插入
# l.append(10)
# print(l)
# 在最前边插入
# l.insert(0,0)
# print(l)
# 在末尾插入
# l.insert(100,100)
# print(l)
# 在倒数第一个位置插入
# l.insert(-1,-1)
# print(l)
# 在最开始插入
# l.insert(-100,-100)
# print(l)

# 获取某一个值的下标
# print(l.index(3))
# print(l.index(5))
# print(l.index(8))
# print(l.index(10))

# 删除元素
# 删除末尾元素
# l.pop()
# print(l)
# 删除下标为3的元素
# l.pop(3)
# print(l)
#
# 删除值为7的元素
# l.remove(7)
# print(l)

# 列表拼接
# a=['hello',True,1.22]
# k=a+l
# print(f'a:{a}')
# print(f'l:{l}')
# print(f'k:{k}')
# # extend操作是直接拼接列表，+=操作需要构造更大的列表，把旧a空间中的数据拷贝到新空间中，再销毁旧a空间，再把b拼接到后边
# b=['a','c',False,1,4,3]
# # a+=b
# c=a.extend(b)
# print(f'a:{a}')
# print(f'c:{c}')

# 元组不可修改
# a=(1,2,3)
# b=tuple()
# print(a)
# print(b)
#
# c=(4,5,6)
# d=a+c
# print(d)

# a={'id':1,"name":"haha",'phone':123345,123:"hello"}
# b=dict()
# python的哈希表(dict)，能保证输入和输出顺序一致
# print(a)
# print(b)
# for k in a:
#     print(f'{k}:{a[k]}')

# print('id' in a)
# # 只判断key，不管val
# print('haha' in a)
# # []操作度比in效率更高
# print(a['id'])
# print(a[123])

# 插入数据
# a['score']=100
# print(a)
#
# # 修改数据
# a['phone']=987654321
# print(a)
#
# # 获取所有key
# b=a.keys()
# print(b)
# print(type(b))
# # 获取所有val
# c=a.values()
# print(c)
# print(type(c))
# # 获取所有kv键值对
# d=a.items()
# print(d)
# print(type(d))
#
# # 删除数据
# a.pop('id')
# print(a)

# print(hash("123456"))
# print(hash(1234))
# print(hash(True))
# print(hash(2.22))
# print(hash((1,2,3,4)))


# list和dict等可变类型是不可hash的
# print(hash([1,2,3]))
# print(hash({'a':1,'b':2}))

# 文件操作
# f=open("./test.txt",'w')
# # print(f)
# # print(type(f))
# f.write("hello")
# f.write("haha")
# f.close()
#
# f=open('./test.txt','r')
# res=f.read()
# print(res)
# f.close()
#
# f=open("./test.txt",'w')
# f.write("zaijian")
# f.close()
#
# f=open('./test.txt','r')
# res=f.read()
# print(res)
# f.close()
# # 以w方式打开文件会清空文件内容，重新写入
# # 以a方式打开文件不会清空文件内容，会在末尾继续写入
# f=open("./test.txt","a")
# f.write("nihao")
# f.close()
#
# f=open('./test.txt','r')
# res=f.read()
# print(res)
# f.close()

# flist = []
# count = 0
# while True:
#      f = open('./test.txt', 'r')
#      flist.append(f)
#      count += 1
#      print(f'count = {count}')

# 读取中文
# f=open('./test.txt','r',encoding='utf8')
# # 换行也是一个字符,一个汉字是一个字符
# res=f.read(5)
# print(res)
# f.close()
#
# # 循环读取文件每一行
# f = open('./test.txt', 'r',encoding='UTF-8')
# lines = f.readlines()
# print(lines)
# f.close()
#
# f = open('./test.txt', 'r',encoding='UTF-8')
# for line in f: #会把换行符也读取到
#     # print(f'line = {line}')
#     print(f'line = {line}',end="")#取消自动换行，每次在末尾加一个""
#
# f.close()
#
# f = open('./test.txt', 'r',encoding='UTF-8')
# lines = f.readlines()
# print(lines)
# f.close()

# 自动关闭文件资源
with open('./test.txt', 'r', encoding='utf8') as f:
    lines = f.readlines()
    print(lines)







